/*////////////////////////////////////////

		Non-Player Default Settings
			*Configuration*
			
*/////////////////////////////////////////

GAME.NPCDefaultData = {};

	GAME.NPCDefaultData["Inventory"] = {};
	GAME.NPCDefaultData["Faction"] = "Military";
	GAME.NPCDefaultData["Flags"] = "N";
	GAME.NPCDefaultData["Name"] = "";
	GAME.NPCDefaultData["Equipment"] = { ["Misc"] = "foo", ["Secondary"] = "foo", ["Primary"] = "foo" };
	GAME.NPCDefaultData["Gear"] ={};
	
if !GAME.MasterTable["NPCTable"] then GAME.SetData("NPCData");end
	
	
/*////////////////////////////////////////
			*Controls*		
*/////////////////////////////////////////

concommand.Add("gm_npcsetup", function(ply, cmd, args)
	
	if GAME.Debug then
	
		--args[1] must be a bool.
		GAME.SetupNPC(args[1], ply:GetEyeTrace(), Angle( ply:GetAimVector() ));
		
	end

end);

concommand.Add("gm_npcspawnpoint", function(ply, cmd, args)

	if GAME.Debug then
		--Do stuff.
	end
	
end);
	
------------------------------------------

//We need to create an info entity which will basically represent our 'points-of-interest'

--Don't use think but when a player is in a certain radius of the NPC, start ticking a slow tick. Check in that tick if a trace line hits the player.

--Enemy awareness, if an enemy is spotted then place him into a 'spotted' table, check for him and after a certain while just 'forget him' and remove him from the table. 

//Create basic NPC shit(spawning and respawning and info... gotta fix MasterData) then go ahead and create NPC types and world inventories(stashes)

/*////////////////////////////////////////

		NPC Function Workshop
			*Configuring...*
			
*/////////////////////////////////////////

--This will initialize an NPC's data, that doesn't neccisarily mean that he will 'physically' be created but his data will.
function GAME.NPCInitialize()

end

function GAME.NPCRespawn(data)

end

--Create this NPC a data faculty, create himself if he is active or just store his awaiting facility.
function GAME.SetupNPC(active, pos, angles)

	local ID = "npc_"..CurTime();
	local data = GAME.GetData["NPCData"];
		
		data[ID] = false;
		
	GAME.SetData("NPCData", data);
	
	if active then
		
		local ent = ents.Create("npc");
			
			ent:SetPos( pos );
			ent:SetAngles( angles );
			ent:SetModel( "models/humans/group01/male_02.mdl" );
			
		ent:Spawn();
		ent:SetVar("ID", ID);
		
		ent:InitializeData();		
	
	end

end

function GAME.NPCSetData(id, index, info)
	
	local data = GAME.GetData["NPCData"];
	
	if !data[id] then data[id] = {};GAME.SetData("NPCData", data);end
		
		data[id][index] = info;
		
	GAME.SetData("NPCData", data);
	
	return data;

end

function GAME.NPCGetData(id, index)

	return GAME.MasterTable["NPCData"][id][index] or {};
	
end

local NPC = FindMetaTable("NPC");

function NPC:InitializeData()

	for key, value in pairs(GAME.NPCDefaultData) do
		
		GAME.NPCSetData( self:GetVar("ID"), key, value );
		
	end

end

